home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / AOCE / Development Tools / Sample Code / Interprogram Messaging Manager / IPM MessageBoard / trapavailable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  1.2 KB  |  66 lines  |  [TEXT/MPS ]

  1. /*-------------------------------------------------------------------------------------
  2.  *
  3.  * IPM MessageBoard AOCE Sample
  4.  *
  5.  * ©1992-1993 Apple Computer
  6.  *
  7.  -------------------------------------------------------------------------------------*/
  8. /*
  9.  * trapavailable.c -- checks to see if a trap is implemented
  10.  *
  11.  * change history:
  12.  *
  13.  * SJF        2/12/93        1.0b1        udpate to AOCE beta seed
  14.  * SJF        11/6/91        1.0d1        initial coding
  15.  *
  16.  */
  17.  
  18. #ifndef __TYPES__
  19. #include <Types.h>
  20. #endif
  21.  
  22. #ifndef __TRAPS__
  23. #include <Traps.h>
  24. #endif
  25.  
  26. #ifndef __OSUTILS__
  27. #include <OSUtils.h>
  28. #endif
  29.  
  30. #include "trapavailable.h"
  31.  
  32. short NumToolboxTraps(void);
  33. TrapType GetTrapType(short theTrap);
  34.     
  35. short NumToolboxTraps(void)
  36. {
  37.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  38.         return 0x0200;
  39.     else
  40.         return 0x0400;
  41. }
  42.  
  43. TrapType GetTrapType(short theTrap)
  44. {
  45.     if ((theTrap & 0x0800) > 0)
  46.         return ToolTrap;
  47.     else
  48.         return OSTrap;
  49. }
  50.  
  51. Boolean    TrapAvailable(short theTrap)
  52. {
  53.     TrapType tType;
  54.     Boolean isAvail;
  55.     
  56.     tType = GetTrapType(theTrap);
  57.     if (tType == ToolTrap)
  58.         {
  59.             theTrap &= 0x07FF;
  60.             if (theTrap >= NumToolboxTraps())
  61.                 theTrap = _Unimplemented;
  62.         }
  63.     
  64.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  65.     return isAvail;
  66. }